#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>


void *func1(void* arg){

	static int ret = 666;

	printf("t1:%ld\n",(unsigned long)pthread_self());
	printf("t1:param is %d\n",*(int*)arg);
	pthread_exit((void*)&ret);
}



int main(){

//	int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
//                          void *(*start_routine) (void *), void *arg);

	pthread_t t1;
	int ret;
	int param = 100;
	int *ret2;

	ret = pthread_create(&t1,NULL,&func1,(void*)&param);
	if(ret == 0){
	
		printf("main: create t1 success\n");
		printf("main: id is %ld\n",(unsigned long)pthread_self());
	}
	else{
		
		printf("main: create t1 error\n");
		exit(-1);
	}

//	int pthread_join(pthread_t thread, void **retval);
	pthread_join(t1,(void **)&ret2);
	printf("exit ret2 = %d\n",*ret2);

	return 0;
}

